<?xml version="1.0" encoding="ISO-8859-1" ?>

<html xmlns="http://www.w3.org/1999/xhtml" 
	  xmlns:h="http://java.sun.com/jsf/html" 
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:p="http://primefaces.org/ui"
	  xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>

</h:head> 

<h:body>
	<ui:composition template="/template.xhtml">

		<ui:define name="conteudo">

			<center>
				<h:form id="form">
						<p:growl id="messages" />
						<p:outputLabel value="#{msg.disciplina} "/>
						<p:inputText value="#{disciplinaManagedBean.query}"/>
						
			           	<p:commandButton value="#{msg.pesquisar}" 
							           	 action="#{disciplinaManagedBean.listarDisciplinas}" update="disciplinas"
							           	 style="font-size: 16px; margin-left: 10px;" styleClass="btn" />
			           		  			
				  		<p:dataTable id="disciplinas" rows="15" paginator="true" paginatorPosition="bottom" pageLinks="5" value="#{disciplinaManagedBean.disciplinas}" var="disciplina" border="1">
				  			 <f:facet name="header">
								<h:outputText value="#{msg.disciplina}" />
							 </f:facet>  
							 <p:column>
							 	<f:facet name="header">
									<h:outputText value="#{msg.nome}" />
								</f:facet>
								<h:outputText value="#{disciplina.nome}" />
							 </p:column>
							 <p:column>
							 	<f:facet name="header">
									<h:outputText value="#{msg.semestre}" />
								</f:facet>
								<h:outputText value="#{disciplina.semestre}" />
							 </p:column>
							 <p:column>
							 	<f:facet name="header">
									<h:outputText value="#{msg.resumo}" />
								</f:facet>
								<h:outputText value="#{disciplina.resumo}" />
							 </p:column>
							 <p:column colspan="2">
							 	<f:facet name="header">
							 		<h:outputText value="#{msg.acao}"/>
							 	</f:facet>
								<p:commandLink process="@this" onclick="confirmacao.show()">
									<f:setPropertyActionListener value="#{disciplina}" target="#{disciplinaManagedBean.disciplina}" />
									<h:graphicImage value="/img/excluir.png" title="#{msg.excluirDisciplina}" style="border: none" />
								</p:commandLink>
								<h:commandLink action="#{disciplinaManagedBean.atualiza}">
									<f:setPropertyActionListener value="#{disciplina}" target="#{disciplinaManagedBean.disciplina}" />
									<h:graphicImage value="/img/editar.png" title="#{msg.editarDisciplina}" style="border: none" />
								</h:commandLink>
								<p:commandLink actionListener="#{disciplinaManagedBean.populaDetalhesDisciplina}" onclick="detalhesDialog.show();" 
						  					   update=":form:cursoDetalhes,:form:professorDetalhes">
						  				<f:attribute name="disciplina" value="#{disciplina}"/>
						  				<h:graphicImage value="/img/lupa.png" title="#{msg.mostrarDetalhes}" style="border: none" />
						  			</p:commandLink>
							  </p:column>
							  				 			  			   
				  	    </p:dataTable>
				  	    
				  	    <p:confirmDialog id="confirmaExclusao" message="#{msg.perguntaExclusao} #{msg.esta} #{msg.minDisciplina}?"
														 header="#{msg.excluirDisciplina}" severity="alert" widgetVar="confirmacao" closable="false">
							<p:commandButton id="confirma" value="#{msg.sim}" oncomplete="confirmacao.hide()" 
											 actionListener="#{disciplinaManagedBean.excluir}" update="@form" />
							 <p:commandButton id="cancela" value="#{msg.nao}" onclick="confirmacao.hide()" 
											  action="#{disciplinaManagedBean.listarDisciplinas}"/>	
						</p:confirmDialog>
				  	    
				  	    <p:dialog header="#{msg.detalhes}" widgetVar="detalhesDialog" showEffect="clip" hideEffect="clip" width="600">  
							
							<p:outputLabel styleClass="labelDetalhes" value="#{msg.cursos}"/>
							<p:dataList id="cursoDetalhes" value="#{disciplinaManagedBean.cursos}" var="curso" styleClass="listCursos">
								<p:outputLabel value="* #{curso.nome}"/>
							</p:dataList>
							
							<p:outputLabel styleClass="labelDetalhes" value="#{msg.professores}"/>
							<p:dataList id="professorDetalhes" value="#{disciplinaManagedBean.professores}" var="professor" styleClass="listProfessores">
								<p:outputLabel value="* #{professor.nome}"/>
							</p:dataList>
			
						</p:dialog>
				  	    
			  	</h:form>
			</center>
		</ui:define>
</ui:composition>
</h:body> 
</html>